#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int N = 0;
    cin >> N;
    vector<int> vec;
    for (int i = 0; i < N; i++)
    {
        int tmp = 0;
        while (cin >> tmp)
        {
            vec.push_back(tmp);
            if (cin.get() == '\n')
                break;
        }
    }
    sort(vec.begin(), vec.end());
    int m = 0, n = 0;
    for (int i = 1; i < vec.size(); i++)
    {
        if (vec[i] == vec[i - 1] + 2)
            m = vec[i - 1] + 1;
        if (vec[i] == vec[i - 1])
            n = vec[i];
    }
    cout << m << " " << n;
    return 0;
}